from race.Player import *
import logging.config
from wowThread.threadJob import *
from pynput.keyboard import Key

logging.config.fileConfig('./util/logging.conf')
log = logging.getLogger("example")

"""
    子类描述：
        1、术士dps类
"""


class emSS(Player):
    # 恶魔术士(有宝宝，像猎人)

    def on_keyboard_press_son_before_thread(self, key):
        log.debug("on_keyboard_press_son_before_thread 1:进入了函数")
        # 有些按键是直接终止别人的，继续自己的，有些不是这样的，因此要区别对待【排列组合，情况非常多】/【也要超级符合每个职业的操作习惯】
        if key in (
                Key.f1, Key.f2, Key.f3, Key.f4, Key.f5, Key.f6, Key.f7, Key.f8, Key.f9, Key.f10, Key.f11,
                Key.f12):
            pass
        elif key == Key.enter:
            pass
        elif key == Key.space:
            pass
        elif key == Key.alt_l:
            pass
        elif key == Key.ctrl_l:
            pass
        elif key == Key.caps_lock:
            pass
        elif key == Key.shift_l:
            pass
        elif key.char == 'a':
            # 不终止别人，后面让只允许一个线程执行的逻辑来顺序排
            # ★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|
            # 并行并发执行的折中方案【通过触发其他按键，这样的好处是线程池统一管理了】
            pass
        elif key.char == 'z':
            pass
        elif key.char == 'q':
            pass
        elif key.char == 'w':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'r':
            # 终止掉别人
            # interruptAllByForce()
            pass
        elif key.char == 'g':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'x':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'v':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'h':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'c':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'e':
            pass
        elif key.char == 's':
            pass
        elif key.char == 'd':
            pass
        elif key.char == 'f':
            pass
        elif key.char == 'b':
            pass
        return

    # 执行父类的方法
    # @logAop
    def a(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        # #self.startScheduler3()  # 调用 CallBackScheduler3
        self.startScheduler4()  # 调用 CallBackScheduler3
        return

    def CallBackScheduler1(self):
        # 恶魔术士(AOE)
        while self.ui.stopLoop == False:
            self.click(self.kb, '1', 2)
            sleep(0.1)
            self.click(self.kb, '2', 10)
            sleep(0.1)
            self.click(self.kb, '3', 8)
            sleep(0.1)
            self.click(self.kb, '4', 8)
            sleep(0.1)
            self.click(self.kb, 'l', 2)
        return

    def CallBackScheduler2(self):
        # 恶魔术士(AOE)
        while self.ui.stopLoop == False:
            self.click(self.kb, '5', 4)
            sleep(0.1)
            self.click(self.kb, '9', 4)
            sleep(0.1)
            self.click(self.kb, '7', 8)
            # sleep(0.1)
            # self.click(self.kb, '8', 8)
            sleep(0.1)
            self.click(self.kb, 'k', 2)
        return

    def CallBackScheduler8(self):
        # 恶魔术士(AOE)
        while self.ui.stopLoop == False:
            # 小鬼内爆
            sleep(0.1)
            self.click(self.kb, '8', 10)
            sleep(0.1)
            self.click(self.kb, Key.f10, 4)
            sleep(0.1)
            self.click(self.kb, Key.f11, 4)
            sleep(0.1)
            self.click(self.kb, Key.f12, 4)
            sleep(0.1)
        return


    def CallBackScheduler3(self):
        # 恶魔术士（切目标）
        while self.ui.stopLoop == False:
            self.click(self.kb, Key.tab, 1)
            sleep(6)
        return

    def CallBackScheduler4(self):
        # 恶魔术士(AOE)
        while self.ui.stopLoop == False:
            self.click(self.kb, '2', 8)
            sleep(0.3)
            # 恶魔之核心（有恶魔之核，才打顺发恶魔之箭）
            # self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X1, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
            #                                 self.WABloodBarDeltaY,
            #                                 self.WA_SQUARE_ZFX_AvgColor,
            #                                 self.RED, 'small', '6', 0.06, 4, self.ELSEKEY_0 ,self.DEBUG_CLOSE)
            self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X1, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                              self.WABloodBarDeltaY,
                                              self.WA_SQUARE_ZFX_AvgColor,
                                              self.RED, 'big', '6', 0.06, 2, self.ELSEKEY_9 ,self.DEBUG_CLOSE)
        return

    def CallBackScheduler5(self):
        # 恶魔术士(NOT AOE)
        while self.ui.stopLoop == False:
            self.click(self.kb, '2', 8)
            sleep(0.3)
            # 恶魔之核心（有恶魔之核，才打顺发恶魔之箭）
            # self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X1, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
            #                                 self.WABloodBarDeltaY,
            #                                 self.WA_SQUARE_ZFX_AvgColor,
            #                                 self.RED, 'small', '6', 0.06, 4, self.ELSEKEY_0 ,self.DEBUG_CLOSE)
            self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X1, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                              self.WABloodBarDeltaY,
                                              self.WA_SQUARE_ZFX_AvgColor,
                                              self.RED, 'big', '6', 0.06, 2, self.ELSEKEY_9 ,self.DEBUG_CLOSE)
        return

    def v(self):
        self.startScheduler3()
        return

    def on_mouse_scroll_son_before_thread(self, dx, dy):
        # 让鼠标上下切换比较自由方便，中间不需要按Z键进行中转
        if dy < 0:
            # 滚轮向下
            self.interruptAllByForceMouseUpDown()  # 强制打断正在运行的循环
        elif dy > 0:
            # 滚轮向上
            self.interruptAllByForceMouseUpDown()  # 强制打断正在运行的循环
        return
    
    def mouseUp(self, x, y):
        # 恶魔术士
        self.ui.stopLoop = True
        sleep(0.1)
        self.ui.stopLoop = False
        # 手工补尖刺
        log.debug('★鼠标向上滚，需要开始执行的内容★')
        # 手工开T的防护恶魔大招
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        self.startScheduler4()
        self.startScheduler8()  # 有内爆炸+开饰品
        log.debug('★鼠标向上滚，需要over执行的内容★')

        return

    def mouseDown(self, x, y):
        # 恶魔术士
        self.ui.stopLoop = True
        sleep(0.1)
        self.ui.stopLoop = False
        # 手工开T的防护恶魔大招
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        self.startScheduler4()
        # self.startScheduler8()  # 无内爆
        return

    def x(self):
        # 恶魔术士
        for i in range(1, 6):
            self.click(self.kb, '\\', 3)
            sleep(0.1)

        # 打断后的继续
        # 手工开T的防护恶魔大招
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        return

    def z(self):
        # 恶魔术士
        self.ui.stopLoop = True
        # sleep(0.1)
        # self.ui.stopLoop = False
        self.startScheduler5()
        return


    def CallBackScheduler5(self):
        # 恶魔术士
        for i in range(1, 3):
            self.click(self.kb, '\'', 1)
            sleep(0.5)
        return

class hmSS(Player):
    # 毁灭术士

    def on_keyboard_press_son_before_thread(self, key):
        log.debug("on_keyboard_press_son_before_thread 1:进入了函数")
        # 有些按键是直接终止别人的，继续自己的，有些不是这样的，因此要区别对待【排列组合，情况非常多】/【也要超级符合每个职业的操作习惯】
        if key in (
                Key.f1, Key.f2, Key.f3, Key.f4, Key.f5, Key.f6, Key.f7, Key.f8, Key.f9, Key.f10, Key.f11,
                Key.f12):
            pass
        elif key == Key.enter:
            pass
        elif key == Key.space:
            pass
        elif key == Key.alt_l:
            pass
        elif key == Key.ctrl_l:
            pass
        elif key == Key.caps_lock:
            pass
        elif key == Key.shift_l:
            pass
        elif key.char == 'a':
            # 不终止别人，后面让只允许一个线程执行的逻辑来顺序排
            # ★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|
            # 并行并发执行的折中方案【通过触发其他按键，这样的好处是线程池统一管理了】
            pass
        elif key.char == 'z':
            pass
        elif key.char == 'q':
            pass
        elif key.char == 'w':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'r':
            # 终止掉别人
            # interruptAllByForce()
            pass
        elif key.char == 'g':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'x':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'v':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'h':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'c':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'e':
            pass
        elif key.char == 's':
            pass
        elif key.char == 'd':
            pass
        elif key.char == 'f':
            pass
        elif key.char == 'b':
            pass
        return

    # 执行父类的方法
    # @logAop
    def a(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        # #self.startScheduler3()  # 调用 CallBackScheduler3
        self.startScheduler4()  # 调用 CallBackScheduler3
        return

    def CallBackScheduler1(self):
        while self.ui.stopLoop == False:
            self.click(self.kb, Key.f4, 2)
            sleep(0.1)
            self.click(self.kb, '2', 10)
            sleep(0.1)
            self.click(self.kb, '1', 8)
            sleep(0.1)
            self.click(self.kb, '4', 8)
            sleep(0.1)
            self.click(self.kb, 'l', 2)
        return

    def CallBackScheduler2(self):
        while self.ui.stopLoop == False:
            self.click(self.kb, '5', 4)
            sleep(0.1)
            self.click(self.kb, '9', 4)
            sleep(0.1)
            self.click(self.kb, '7', 8)
            sleep(0.1)
            self.click(self.kb, '8', 8)
            sleep(0.1)
            self.click(self.kb, 'k', 2)
            sleep(0.1)
            self.click(self.kb, '0', 4)
        return

    def CallBackScheduler3(self):
        while self.ui.stopLoop == False:
            self.click(self.kb, Key.tab, 1)
            sleep(6)
        return

    def CallBackScheduler4(self):
        while self.ui.stopLoop == False:
            self.click(self.kb, '3', 8)
            sleep(0.3)
            # # 毁灭术士，待定
            # self.pubAvgColorTiggerKeyCDMode(self.WA_SQUARE_ZFX_X1, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
            #                                 self.WABloodBarDeltaY,
            #                                 self.WA_SQUARE_ZFX_AvgColor,
            #                                 self.RED, 'big', '6', 0.06, 4, self.ELSEKEY_0 ,self.DEBUG_CLOSE)
        return

    def v(self):
        self.startScheduler3()
        return

    def on_mouse_scroll_son_before_thread(self, dx, dy):
        # 让鼠标上下切换比较自由方便，中间不需要按Z键进行中转
        if dy < 0:
            # 滚轮向下
            self.interruptAllByForceMouseUpDown()  # 强制打断正在运行的循环
        elif dy > 0:
            # 滚轮向上
            self.interruptAllByForceMouseUpDown()  # 强制打断正在运行的循环
        return

    def mouseUp(self, x, y):
        self.ui.stopLoop = True
        sleep(0.1)
        self.ui.stopLoop = False
        # 手工开T的防护恶魔大招
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        self.startScheduler4()
        return

    def mouseDown(self, x, y):
        self.ui.stopLoop = True
        sleep(0.1)
        self.ui.stopLoop = False
        # 手工开T的防护恶魔大招
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        self.startScheduler4()
        return

    def x(self):
        for i in range(1, 6):
            self.click(self.kb, '\\', 3)
            sleep(0.1)

        # 打断后的继续
        # 手工开T的防护恶魔大招
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        return